import Vue from 'vue'

import Cookies from 'js-cookie'
import '@/assets/iconfont/iconfont.css'
import 'normalize.css/normalize.css'
import Element from 'element-ui'
//
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'

// 数据字典
import dict from './components/Dict'

// 权限指令
import checkPer from '@/utils/permission'
import permission from './components/Permission'
import './assets/styles/element-variables.scss'
// global css
import './assets/styles/index.scss'

// 代码高亮
import VueHighlightJS from 'vue-highlightjs'
import 'highlight.js/styles/atom-one-dark.css'

import App from './App'
import store from './store'
import router from './router/routers'

import './assets/icons' // icon
import './router/index' // permission control
import 'echarts-gl'
import * as filters from './filters' // global filters
import echarts from 'echarts'

Vue.prototype.$echarts = echarts
Element.Dialog.props.closeOnClickModal.default = false

Vue.use(checkPer)
Vue.use(VueHighlightJS)
Vue.use(mavonEditor)
Vue.use(permission)
Vue.use(dict)
Vue.use(Element, {
  size: Cookies.get('size') || 'small' // set element-ui default size
})
Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key])
  })

Vue.config.productionTip = false
Array.prototype.remove = function (val) {
  var index = this.indexOf(val);
  if (index > -1) {
    this.splice(index, 1);
  }
};
Array.deepCopy = function (obj) {
  var newobj = obj.constructor === Array ? [] : {};
  if(typeof obj !== 'object'){
      return;
  }
  for(var i in obj){
     newobj[i] = typeof obj[i] === 'object' ? this.deepCopy(obj[i]) : obj[i];
  }
  return newobj
}
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
